home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / xless / xless141.z / xless141 / xless-1.4.1 / xless.h < prev    next >
C/C++ Source or Header  |  1993-05-05  |  8KB  |  263 lines

  1. /*
  2.  * Copyright 1989 Massachusetts Institute of Technology
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and its
  5.  * documentation for any purpose and without fee is hereby granted, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of M.I.T. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  M.I.T. makes no representations about the
  11.  * suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  15.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  16.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  17.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  18.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  19.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  20.  *
  21.  * Author: Carlo Lisa
  22.  *       MIT Project Athena
  23.  *       carlo@athena.mit.edu
  24.  *
  25.  *
  26.  *      This is the file xless.h for XLess, a file browsing utility
  27.  *      built upon Xlib and the XToolkit.
  28.  *      It contains: Lots of good definitions.
  29.  *
  30.  *    $Header: /usr/sww/share/src/X11R5/local/clients/xless-1.4/RCS/xless.h,v 1.33 1993/04/30 21:39:15 dglo Exp dglo $
  31.  *
  32.  */
  33.  
  34. /* Std system and C include files */
  35.  
  36. #include <stdio.h>
  37. #include <X11/Xos.h>
  38. #include <sys/dir.h>
  39. #include <sys/stat.h>
  40.  
  41. /* X include files */
  42.  
  43. #include <X11/X.h>
  44. #include <X11/Xatom.h>
  45. #include <X11/StringDefs.h>
  46.  
  47. /* X toolkit Include files */
  48.  
  49. #include <X11/Intrinsic.h>
  50. #include <X11/Shell.h>
  51. #include <X11/cursorfont.h>
  52.  
  53. #  include <X11/Xaw/AsciiText.h>
  54. #  include <X11/Xaw/Text.h>
  55. #  include <X11/Xaw/Command.h>
  56. #  include <X11/Xaw/Viewport.h>
  57. #  include <X11/Xaw/Box.h>
  58. #  include <X11/Xaw/Label.h>
  59. #  include <X11/Xaw/Paned.h>
  60. #  include <X11/Xaw/Form.h>
  61.  
  62. #include <malloc.h>
  63.  
  64. /* Useful defines */
  65.  
  66. #define MEMBUF        512000
  67. #define BOXWIDTH    500
  68. #define BOXHEIGHT    50
  69. #define BUTTONWIDTH    100
  70. #define BUTTONHEIGHT    18
  71. #define DIALOGWIDTH    350
  72. #define DIALOGHEIGHT    150
  73. #define MAX_INPUT    256
  74. #define DEF_INPUT_W    200
  75. #define INPUT_HEIGHT    6
  76.  
  77. /* handle differences between K&R and ANSI C */
  78. #if __STDC__
  79. #define ARGS(a)    a
  80. #else
  81. #define ARGS(a)    ()
  82. #define const
  83. #endif
  84.  
  85. /*
  86.  * The environment variable containing the favorite editor.
  87.  */
  88.  
  89. #define EDITORVAR "EDITOR"
  90.  
  91. /*
  92.  * The default editor; make sure the file exists.
  93.  * (Used if the environment variable EDITOR is not set)
  94.  */
  95.  
  96. #ifndef DEFEDITOR
  97. #define DEFEDITOR "/usr/ucb/vi"
  98. #endif
  99.  
  100. /*
  101.  * This is the default helpfile and is site specific,
  102.  * make sure you change this.
  103.  */
  104.  
  105. #ifndef HELPFILE
  106. #define HELPFILE "/usr/lib/X11/xless.help"
  107. #endif
  108.  
  109. /*
  110.  * This is the default print command and is OS specific.
  111.  * It should probably be "lpr" for BSD, "lp" for SysV
  112.  */
  113.  
  114. #ifndef PRINTCMD
  115. #define PRINTCMD "/usr/ucb/lpr"
  116. #endif
  117.  
  118. /*
  119.  * Application class.  You shouldn't change this.
  120.  */
  121. #define XLESS_CLASS "XLess"
  122.  
  123. /* Default fonts. */
  124. #define STANDARDCUR "left_ptr"
  125.  
  126. #define STANDARDFONT "fixed"
  127. #define TEXTFONT "-adobe-helvetica-medium-r-normal--12-120-*-*-p-67-iso8859-1"
  128. #define LABELFONT "-adobe-times-bold-i-normal--24-240-*-*-p-128-iso8859-1"
  129. #define BUTTONFONT "-adobe-times-bold-r-normal--14-140-*-*-p-77-iso8859-1"
  130.  
  131. /* Typedefs */
  132.  
  133. /*
  134.  * Values for WindowInfo flag
  135.  */
  136. typedef enum _XLessFlagBits {
  137.   XLessClearFlag = 0x00,        /* turn off all bits */
  138.   XLessFreeFilename = 0x01,        /* filename uses malloc'd memory */
  139. } XLessFlag;
  140.  
  141. /*
  142.  * This structure holds everything xless needs to know about
  143.  * each of its windows.
  144.  */
  145. typedef struct _WindowInfo {
  146.   struct _WindowInfo *next;
  147.   Widget base;
  148.   Widget text;
  149.   Widget toolbox;
  150.   Widget search_popup;
  151.   Widget newwin_popup;
  152.   Widget chgfile_popup;
  153.   Widget editor_button;
  154.   Widget reload_button;
  155.   const char *memory;
  156.   const char *file;
  157.   XLessFlag flag;
  158. } WindowInfo;
  159.  
  160. typedef struct _XLessFonts {
  161.   XFontStruct
  162.     *standard,    /* The font used if no fonts specied */
  163.     *text,            /* Font used for XLess text */
  164.     *label,            /* Font used for labels in dialog boxes */
  165.     *button;        /* Font used for commandbuttons */
  166. } XLessFonts;
  167.  
  168. typedef struct _XLessCursors {
  169.   Cursor
  170.     top,            /* The top cursor, default for XLess */
  171.     dialog;            /* Cursor for dialog boxes */
  172. } XLessCursors;
  173.  
  174. /* Resource manager sets these */
  175.  
  176. typedef struct _XLessResources {
  177.   XLessFonts fonts;        /* The fonts used for XLess */
  178.   XLessCursors cursors;        /* The cursors used for XLess */
  179.   char *help_file;        /* The help file name */
  180.   Boolean editorDoesWindows;    /* does editor come up in a window? */
  181.   char *printCmd;        /* command used to print file */
  182.   int maxWindows;        /* maximum number of open windows */
  183.   Boolean quitButton;        /* does user want a QUIT button? */
  184.   char *textGeometry;        /* width/height of text window */
  185.   char *namePrefix;        /* string to prepend to file name */
  186.   Boolean removePath;        /* does user want path junk removed? */
  187.   Boolean sizeToFit;        /* should window be as small as possible? */
  188.   Boolean helpMessage;        /* should we just print a help msg and exit? */
  189. } XLessResources;
  190.  
  191. /* External prototypes */
  192. char *getenv ARGS((const char *));
  193. #ifdef ALL_EXTERNAL_PROTOTYPES
  194. int fclose ARGS((FILE *));
  195. char *fprintf ARGS((FILE *, const char *, ...));
  196. int fputs ARGS((const char *, FILE *));
  197. int fread ARGS((char *, int, int, FILE *));
  198. void *malloc ARGS((size_t));
  199. void *realloc ARGS((void *, size_t));
  200. int system ARGS((const char *));
  201. struct passwd *getpwnam ARGS((const char *));
  202. char *strchr ARGS((const char *, int));
  203. #endif /* ALL_EXTERNAL_PROTOTYPES */
  204.  
  205. /* prototypes from help.c */
  206. void PopupHelp ARGS((Widget, XtPointer, XtPointer));
  207.  
  208. /* prototypes from init.c */
  209. const char *InitData ARGS((FILE *));
  210. Widget MakeToolbox ARGS((Widget, WindowInfo *, const char *));
  211. Widget MakeText ARGS((Widget, const char *));
  212. void SetXNames ARGS((Widget, const char *));
  213.  
  214. /* prototypes from popup.c */
  215. Widget DialogBox ARGS((Widget, XtCallbackProc, XtPointer, const char *,
  216.                const char *, char *));
  217. Widget MessageBox ARGS((Widget, const char *, ...));
  218. WindowInfo *MakeDialog ARGS((Widget));
  219.  
  220. /* prototypes from util.c */
  221. void SetPopup ARGS((Widget, Widget));
  222. void DoSearch ARGS((Widget, const char *, const char *, Widget));
  223. void CheckFonts ARGS((void));
  224. void SetReadText ARGS((Widget, char *));
  225. void CouldntOpen ARGS((Widget, const char *));
  226. const char *TildeExpand ARGS((const char *));
  227. extern XFontStruct *buttonfont;
  228. extern XFontStruct *labelfont;
  229. extern XFontStruct *textfont;
  230. extern Cursor stdcur;
  231. extern Cursor dialogcur;
  232.  
  233. /* prototypes from callbacks.c */
  234. void Quit ARGS((Widget, XtPointer, XtPointer));
  235. void SearchNext ARGS((Widget, XtPointer, XtPointer));
  236. void Cancel ARGS((Widget, XtPointer, XtPointer));
  237. void CallEditor ARGS((Widget, XtPointer, XtPointer));
  238. void Reload ARGS((Widget, XtPointer, XtPointer));
  239. void Search ARGS((Widget, XtPointer, XtPointer));
  240. void ChangeFile ARGS((Widget, XtPointer, XtPointer));
  241. void NewWindow ARGS((Widget, XtPointer, XtPointer));
  242. void CloseWindow ARGS((Widget, XtPointer, XtPointer));
  243. void Print ARGS((Widget, XtPointer, XtPointer));
  244.  
  245. /* prototypes from functions.c */
  246. void QuitFunction ARGS((void));
  247.  
  248. /* prototypes from main.c */
  249. void cleanup ARGS((void));
  250. extern Display *disp;
  251. extern XLessResources resources;
  252.  
  253. /* prototypes from window.c */
  254. int CreateWindow ARGS((Widget, const char *));
  255. void DestroyWindowInfo ARGS((WindowInfo *));
  256. void DestroyAllWindows ARGS((void));
  257. extern WindowInfo *windowlist;
  258. extern int windowcount;
  259.  
  260. /* prototypes from actions.c */
  261. extern XtActionsRec actions[];
  262. extern Cardinal numactions;
  263.